<?php
namespace app\admin\controller;
use think\Controller;


/**
 * 门店管理
 */
class Location extends  Controller
{
    private $obj;
    public function _initialize()
    {
        $this->obj = model("BisLocation");
    }

    /**
     * 门店列表，  审核已通过  status=1
     * @return mixed
     */
    public function index()
    {
        $bislocation = $this->obj->getBisLocationByStatus(1);
        return $this->fetch('', [
            'bislocation' => $bislocation,
        ]);
    }

    /**
     * 门店申请  status=0 待审
     */
    public function apply() {
        $bislocation = $this->obj->getBisLocationByStatus(0);
        return $this->fetch('', [
            'bislocation' => $bislocation,
        ]);
    }

    /**
     * 进行审核
     * @return mixed
     */
    public function detail(){
        return $this->fetch();
    }

    /**
     * 删除的商户 ：status=-1
     */
    public function dellist() {
        $bislocation = $this->obj->getBisLocationByStatus(-1);
        return $this->fetch('', [
            'bislocation' => $bislocation,
        ]);
    }

    /**
     * 修改门店状态 status
     */
    public function status() {
        $data = input('get.');

        $validate=validate('Bis');
        if (!$validate->scene('status')->check($data)){
            $this->error($validate->getError());
        }

        $res = $this->obj->save(['status'=>$data['status']], ['id'=>$data['id']]);
        if($res) {
            $this->success('更新成功');
        }else {
            $this->error('更新失败');
        }
    }
}